<html>
<head>
<h1>Add New course</h1>
</head>

<body>
<form action="addcourses.php" method="GET">
Course Id: <input type='text' name = 'cid' /> <br/>
Course Name: <input type='text' name = 'cname' /> <br/>
Course Number: <input type='text' name = 'cnumber' /> <br/>
Department ID: <input type='text' name = 'did' /> <br/>
Current Term: <input type='text' name = 'term' /> <br/>
<input type='submit' name = 'create' value='Add'/>
</form>
</body>
<?php
	require "config.php";
	error_reporting(0);
	
	$cid = $_GET['cid'];
	$cname = $_GET['cname'];
	$cnumber = $_GET['cnumber'];
	$did = $_GET['did'];
	$term = $_GET['term'];
	
	$con = mysql_connect("localhost",$db_user ,$db_pass);

	// if an error was encountered, the script exits with an error message
	if (!$con){
		die('Could not connect: ' . mysql_error());
    }
	//after successfully connecting with the database server, select the database with which you want to communicate
	mysql_select_db($db_name, $con);
	
	$sql_add = "INSERT INTO course (courseId,courseName,courseNumber,departmentId,curentTerm) VALUES ('$cid', '$cname','$cnumber','$did','$term');";
	$result1 = mysql_query($sql_add);
	echo "added";
	mysql_close($con);
?>
<br />
<a href="student.php">Home</a>
</html>
